<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<html>
<head>
	<base href="<%=basePath%>">
<meta charset="UTF-8">
<link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />

<script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
<script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
	<script>
		$(function () {
			//为修改数据绑定事件并做出判断
			$("#updateBtn").click(function () {
			var $select=	$("input[name=select]:checked");
			if ($select.length==0){
				alert("请选择修改的数据")
			}else if($select.length>1){
				alert("请选择一条数据修改")

			}else {
				var code = $select.val();
				//alert(code)

				window.location.href="settings/dictionary/value/toValueEdit.do?code="+code;



			}

			})

			//挑勾选项的处理
			//单选勾——————>全选勾
			$("input[name=select]").click(function () {
				$("#selectAll").prop("checked",$("input[name=select]:checked").length==$("input[name=select]").length)
			})

			$("#selectAll").click(function () {
				$("input[name=select]").prop("checked",this.checked)
			})


			//为删除按钮绑定事件，并做出约束
			$("#deleteValueBtn").click(function () {
				//取得删除数据的id
				var $select = $("input[name=select]:checked")
				var  flag ="";
				if ($select.length==0){
					alert("请选择一条你需要删除的数据")
				} else {
					if (confirm("你确定要删除以下数据吗？")) {
						
						for (var i= 0;i<$select.length;i++){
							
							flag= flag+ "ids="+$($select[i]).val();
							
							if (i<$select.length){
								flag+= "&"
							}
							
						}
						//alert(flag)

						window.location.href=window.location.href="settings/dictionary/value/deleteValue.do?"+flag;
				}
					
					
					
				}
				
				

			})








		})








	</script>


</head>
<body>

	<div>
		<div style="position: relative; left: 30px; top: -10px;">
			<div class="page-header">
				<h3>字典值列表</h3>
			</div>
		</div>
	</div>
	<div class="btn-toolbar" role="toolbar" style="background-color: #F7F7F7; height: 50px; position: relative;left: 30px;">
		<div class="btn-group" style="position: relative; top: 18%;">
		  <button type="button" class="btn btn-primary"
				  onclick="window.location.href='settings/dictionary/value/toValueSave.do'"><span
				  class="glyphicon glyphicon-plus"></span> 创建</button>
		  <button type="button" class="btn btn-default" id="updateBtn"
				  <%--onclick="window.location.href='settings/dictionary/value/toEdit.do'"--%>><span
				  class="glyphicon glyphicon-edit" ></span> 编辑</button>
		  <button type="button" class="btn btn-danger"id="deleteValueBtn"><span class="glyphicon glyphicon-minus"
															 ></span> 删除
		  </button>
		</div>
	</div>
	<div style="position: relative; left: 30px; top: 20px;">
		<table class="table table-hover">
			<thead>
				<tr style="color: #B3B3B3;">
					<td><input type="checkbox" id="selectAll"/></td>
					<td>序号</td>
					<td>字典值</td>
					<td>文本</td>
					<td>排序号</td>
					<td>字典类型编码</td>
				</tr>
			</thead>
			<tbody>
				<%--<tr class="active">

				<tr class="active">
					<td><input type="checkbox" /></td>
					<td>5</td>
					<td>3</td>
					<td>三级部门</td>
					<td>3</td>
					<td>orgType</td>
				</tr>--%>

			<c:forEach items="${DicValue}" var="dv" varStatus="vs">
				<tr class="active">
					<td><input type="checkbox"  name="select" value="${dv.id}" /></td>
					<td>${vs.count}</td>
					<td>${dv.value}</td>
					<td>${dv.text}</td>
					<td>${dv.orderNo}</td>
					<td>${dv.typeCode}</td>
				</tr>
			</c:forEach>
			</tbody>
		</table>
	</div>
	
</body>
</html>